home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / DeskBus.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  11.3 KB  |  286 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        DeskBus.h
  3.  
  4.      Contains:    Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology:    System 8.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1987-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __DESKBUS__
  18. #define __DESKBUS__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25.     #include <MixedMode.h>
  26. #endif
  27.  
  28.  
  29.  
  30.  
  31. #if PRAGMA_ONCE
  32. #pragma once
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT
  40. #pragma import on
  41. #endif
  42.  
  43. #if PRAGMA_STRUCT_ALIGN
  44.     #pragma options align=mac68k
  45. #elif PRAGMA_STRUCT_PACKPUSH
  46.     #pragma pack(push, 2)
  47. #elif PRAGMA_STRUCT_PACK
  48.     #pragma pack(2)
  49. #endif
  50.  
  51. #if TARGET_OS_MAC
  52. typedef SInt8                             ADBAddress;
  53. #if CALL_NOT_IN_CARBON
  54. typedef CALLBACK_API( void , ADBCompletionProcPtr )(Ptr buffer, Ptr refCon, long command);
  55. /*
  56.     WARNING: ADBCompletionProcPtr uses register based parameters under classic 68k
  57.              and cannot be written in a high-level language without 
  58.              the help of mixed mode or assembly glue.
  59. */
  60. typedef CALLBACK_API( void , ADBDeviceDriverProcPtr )(SInt8 devAddress, SInt8 devType);
  61. /*
  62.     WARNING: ADBDeviceDriverProcPtr uses register based parameters under classic 68k
  63.              and cannot be written in a high-level language without 
  64.              the help of mixed mode or assembly glue.
  65. */
  66. /*
  67.     TempADBServiceRoutineUPP is needed because of circular definition of
  68.     ADBServiceRoutineProcPtr and ADBServiceRoutineUPP depending on each other.
  69. */
  70. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             TempADBServiceRoutineUPP;
  71. typedef CALLBACK_API( void , ADBServiceRoutineProcPtr )(Ptr buffer, TempADBServiceRoutineUPP completionProc, Ptr refCon, long command);
  72. /*
  73.     WARNING: ADBServiceRoutineProcPtr uses register based parameters under classic 68k
  74.              and cannot be written in a high-level language without 
  75.              the help of mixed mode or assembly glue.
  76. */
  77. typedef CALLBACK_API( void , ADBInitProcPtr )(SInt8 callOrder);
  78. /*
  79.     WARNING: ADBInitProcPtr uses register based parameters under classic 68k
  80.              and cannot be written in a high-level language without 
  81.              the help of mixed mode or assembly glue.
  82. */
  83. typedef REGISTER_UPP_TYPE(ADBCompletionProcPtr)                 ADBCompletionUPP;
  84. typedef REGISTER_UPP_TYPE(ADBDeviceDriverProcPtr)                 ADBDeviceDriverUPP;
  85. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             ADBServiceRoutineUPP;
  86. typedef REGISTER_UPP_TYPE(ADBInitProcPtr)                         ADBInitUPP;
  87.  
  88. struct ADBDataBlock {
  89.     SInt8                             devType;                    /* original handler ID */
  90.     SInt8                             origADBAddr;                /* original ADB Address */
  91.     ADBServiceRoutineUPP             dbServiceRtPtr;                /* service routine pointer */
  92.     Ptr                             dbDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  93. };
  94. typedef struct ADBDataBlock                ADBDataBlock;
  95.  
  96. typedef ADBDataBlock *                    ADBDBlkPtr;
  97.  
  98. struct ADBSetInfoBlock {
  99.     ADBServiceRoutineUPP             siService;                    /* service routine pointer */
  100.     Ptr                             siDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  101. };
  102. typedef struct ADBSetInfoBlock            ADBSetInfoBlock;
  103.  
  104. typedef ADBSetInfoBlock *                ADBSInfoPtr;
  105. /* ADBOpBlock is only used when calling ADBOp from 68k assembly code */
  106.  
  107. struct ADBOpBlock {
  108.     Ptr                             dataBuffPtr;                /* buffer: pointer to variable length data buffer */
  109.     ADBServiceRoutineUPP             opServiceRtPtr;                /* completionProc: completion routine pointer */
  110.     Ptr                             opDataAreaPtr;                /* refCon: this field is passed as the refCon parameter to the completion routine */
  111. };
  112. typedef struct ADBOpBlock                ADBOpBlock;
  113.  
  114. typedef ADBOpBlock *                    ADBOpBPtr;
  115. #endif  /* CALL_NOT_IN_CARBON */
  116. EXTERN_API( void )
  117. ADBReInit                        (void)                                                        ONEWORDINLINE(0xA07B);
  118.  
  119. /*
  120.     ADBOp has a different interface for 68k assembly than for everything else
  121.     for 68k assembly the interface is 
  122.     #pragma parameter __D0 ADBOp(__A0,__D0)
  123.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  124. */
  125. /*
  126.     IMPORTANT NOTE:
  127.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  128.     four parameters using 68k register based calling conventions, specifically the completion routine
  129.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  130.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  131.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  132.     the mistake cannot be corrected.
  133.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  134.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  135.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  136.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  137. */
  138. EXTERN_API( OSErr )
  139. ADBOp                            (Ptr                     refCon,
  140.                                  ADBCompletionUPP         compRout,
  141.                                  Ptr                     buffer,
  142.                                  short                     commandNum);
  143.  
  144.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  145.                                                                                             #pragma parameter __D0 CountADBs
  146.                                                                                             #endif
  147. EXTERN_API( short )
  148. CountADBs                        (void)                                                        ONEWORDINLINE(0xA077);
  149.  
  150.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  151.                                                                                             #pragma parameter __D0 GetIndADB(__A0, __D0)
  152.                                                                                             #endif
  153. EXTERN_API( ADBAddress )
  154. GetIndADB                        (ADBDataBlock *            info,
  155.                                  short                     devTableIndex)                        ONEWORDINLINE(0xA078);
  156.  
  157.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  158.                                                                                             #pragma parameter __D0 GetADBInfo(__A0, __D0)
  159.                                                                                             #endif
  160. EXTERN_API( OSErr )
  161. GetADBInfo                        (ADBDataBlock *            info,
  162.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA079);
  163.  
  164.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  165.                                                                                             #pragma parameter __D0 SetADBInfo(__A0, __D0)
  166.                                                                                             #endif
  167. EXTERN_API( OSErr )
  168. SetADBInfo                        (const ADBSetInfoBlock * info,
  169.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA07A);
  170.  
  171. #if OPAQUE_UPP_TYPES
  172.     EXTERN_API(ADBCompletionUPP)
  173.     NewADBCompletionUPP               (ADBCompletionProcPtr    userRoutine);
  174.  
  175.     EXTERN_API(ADBDeviceDriverUPP)
  176.     NewADBDeviceDriverUPP           (ADBDeviceDriverProcPtr    userRoutine);
  177.  
  178.     EXTERN_API(ADBServiceRoutineUPP)
  179.     NewADBServiceRoutineUPP           (ADBServiceRoutineProcPtr userRoutine);
  180.  
  181.     EXTERN_API(ADBInitUPP)
  182.     NewADBInitUPP                   (ADBInitProcPtr            userRoutine);
  183.  
  184.     EXTERN_API(void)
  185.     DisposeADBCompletionUPP           (ADBCompletionUPP        userUPP);
  186.  
  187.     EXTERN_API(void)
  188.     DisposeADBDeviceDriverUPP       (ADBDeviceDriverUPP        userUPP);
  189.  
  190.     EXTERN_API(void)
  191.     DisposeADBServiceRoutineUPP       (ADBServiceRoutineUPP    userUPP);
  192.  
  193.     EXTERN_API(void)
  194.     DisposeADBInitUPP               (ADBInitUPP                userUPP);
  195.  
  196.     EXTERN_API(void)
  197.     InvokeADBCompletionUPP           (Ptr                        buffer,
  198.                                     Ptr                        refCon,
  199.                                     long                    command,
  200.                                     ADBCompletionUPP        userUPP);
  201.  
  202.     EXTERN_API(void)
  203.     InvokeADBDeviceDriverUPP       (SInt8                    devAddress,
  204.                                     SInt8                    devType,
  205.                                     ADBDeviceDriverUPP        userUPP);
  206.  
  207.     EXTERN_API(void)
  208.     InvokeADBServiceRoutineUPP       (Ptr                        buffer,
  209.                                     TempADBServiceRoutineUPP completionProc,
  210.                                     Ptr                        refCon,
  211.                                     long                    command,
  212.                                     ADBServiceRoutineUPP    userUPP);
  213.  
  214.     EXTERN_API(void)
  215.     InvokeADBInitUPP               (SInt8                    callOrder,
  216.                                     ADBInitUPP                userUPP);
  217.  
  218. #else
  219.     enum { uppADBCompletionProcInfo = 0x007B9802 };                 /* register no_return_value Func(4_bytes:A0, 4_bytes:A2, 4_bytes:D0) */
  220.     enum { uppADBDeviceDriverProcInfo = 0x00050802 };                 /* register no_return_value Func(1_byte:D0, 1_byte:D1) */
  221.     enum { uppADBServiceRoutineProcInfo = 0x0F779802 };             /* register no_return_value Func(4_bytes:A0, 4_bytes:A1, 4_bytes:A2, 4_bytes:D0) */
  222.     enum { uppADBInitProcInfo = 0x00000802 };                         /* register no_return_value Func(1_byte:D0) */
  223.     #define NewADBCompletionUPP(userRoutine)                         (ADBCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBCompletionProcInfo, GetCurrentArchitecture())
  224.     #define NewADBDeviceDriverUPP(userRoutine)                         (ADBDeviceDriverUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBDeviceDriverProcInfo, GetCurrentArchitecture())
  225.     #define NewADBServiceRoutineUPP(userRoutine)                     (ADBServiceRoutineUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBServiceRoutineProcInfo, GetCurrentArchitecture())
  226.     #define NewADBInitUPP(userRoutine)                                 (ADBInitUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBInitProcInfo, GetCurrentArchitecture())
  227.     #define DisposeADBCompletionUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  228.     #define DisposeADBDeviceDriverUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  229.     #define DisposeADBServiceRoutineUPP(userUPP)                     DisposeRoutineDescriptor(userUPP)
  230.     #define DisposeADBInitUPP(userUPP)                                 DisposeRoutineDescriptor(userUPP)
  231.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  232.     /* InvokeADBCompletionUPP can't be called from classic 68k without glue code */
  233.     #else
  234.         #define InvokeADBCompletionUPP(buffer, refCon, command, userUPP)  CALL_THREE_PARAMETER_UPP((userUPP), uppADBCompletionProcInfo, (buffer), (refCon), (command))
  235.     #endif
  236.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  237.     #pragma parameter InvokeADBDeviceDriverUPP(__D0, __D1, __A0)
  238.     void InvokeADBDeviceDriverUPP(SInt8 devAddress, SInt8 devType, ADBDeviceDriverUPP userUPP) = 0x4E90;
  239.     #else
  240.         #define InvokeADBDeviceDriverUPP(devAddress, devType, userUPP)     CALL_TWO_PARAMETER_UPP((userUPP), uppADBDeviceDriverProcInfo, (devAddress), (devType))
  241.     #endif
  242.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  243.     /* InvokeADBServiceRoutineUPP can't be called from classic 68k without glue code */
  244.     #else
  245.         #define InvokeADBServiceRoutineUPP(buffer, completionProc, refCon, command, userUPP)  CALL_FOUR_PARAMETER_UPP((userUPP), uppADBServiceRoutineProcInfo, (buffer), (completionProc), (refCon), (command))
  246.     #endif
  247.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  248.     #pragma parameter InvokeADBInitUPP(__D0, __A0)
  249.     void InvokeADBInitUPP(SInt8 callOrder, ADBInitUPP userUPP) = 0x4E90;
  250.     #else
  251.         #define InvokeADBInitUPP(callOrder, userUPP)                     CALL_ONE_PARAMETER_UPP((userUPP), uppADBInitProcInfo, (callOrder))
  252.     #endif
  253. #endif
  254. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  255. #define NewADBCompletionProc(userRoutine)                         NewADBCompletionUPP(userRoutine)
  256. #define NewADBDeviceDriverProc(userRoutine)                     NewADBDeviceDriverUPP(userRoutine)
  257. #define NewADBServiceRoutineProc(userRoutine)                     NewADBServiceRoutineUPP(userRoutine)
  258. #define NewADBInitProc(userRoutine)                             NewADBInitUPP(userRoutine)
  259. #define CallADBCompletionProc(userRoutine, buffer, refCon, command) InvokeADBCompletionUPP(buffer, refCon, command, userRoutine)
  260. #define CallADBDeviceDriverProc(userRoutine, devAddress, devType) InvokeADBDeviceDriverUPP(devAddress, devType, userRoutine)
  261. #define CallADBServiceRoutineProc(userRoutine, buffer, completionProc, refCon, command) InvokeADBServiceRoutineUPP(buffer, completionProc, refCon, command, userRoutine)
  262. #define CallADBInitProc(userRoutine, callOrder)                    InvokeADBInitUPP(callOrder, userRoutine)
  263. #endif  /* TARGET_OS_MAC */
  264.  
  265.  
  266. #if PRAGMA_STRUCT_ALIGN
  267.     #pragma options align=reset
  268. #elif PRAGMA_STRUCT_PACKPUSH
  269.     #pragma pack(pop)
  270. #elif PRAGMA_STRUCT_PACK
  271.     #pragma pack()
  272. #endif
  273.  
  274. #ifdef PRAGMA_IMPORT_OFF
  275. #pragma import off
  276. #elif PRAGMA_IMPORT
  277. #pragma import reset
  278. #endif
  279.  
  280. #ifdef __cplusplus
  281. }
  282. #endif
  283.  
  284. #endif /* __DESKBUS__ */
  285.  
  286.